#pragma once
#include "SerialPort.h"
#include "../FilterSDK/ia.h"

class CSerialPortController
{
public:
	CSerialPortController();
	~CSerialPortController();

	int Init(int  portNo, int  baudRate, EParity  parity, int  dataBits, EStopBits  stopsBits, EFlowControl flowControl, bool recvByLine = false);
	int Terminate() noexcept;
	int IsOpen() noexcept;

	int SetParam(ESerialPortParams paramName, int val) noexcept;
	int Flush() noexcept;

	int WriteBytes(unsigned char* pData, int len) noexcept;
	int WriteString(std::string text);

	int BytesWaiting(int* pLen);
	int ReadBytes(unsigned char* pBuffer, int bufferSize, int bytesToRead) noexcept;

	int SetSerialDataReceiver(ISerialPortReceiver* pSerialReceiver);

private:
	CSerialPort* _pSerialPort;
};

